package gold.digger;

import gold.utils.InputUtil;
import gold.vo.TreeNode;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC606 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String tree2str(TreeNode root) {
            if (null == root) return "()";
            String rootStr = root.val + "";
            if (null == root.left) {
                if (null != root.right) rootStr += "()(" + tree2str(root.right) + ")";
            } else {
                rootStr += "(" + tree2str(root.left) + ")";
                if (null != root.right) rootStr += "(" + tree2str(root.right) + ")";
            }

            return rootStr;
        }
    }

    public void run() {
        System.out.println(new Solution().tree2str(TreeNode.createTree("[1,2,3,4]")));
        System.out.println(new Solution().tree2str(TreeNode.createTree("[1,2,3,null,4]")));
    }

    public static void main(String[] args) throws Exception {
        LC606 an = new LC606();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
